<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>DeathGhost-我的购物车</title>
		<meta name="keywords" content="DeathGhost,DeathGhost.cn,web前端设,移动WebApp开发" />
		<meta name="description" content="DeathGhost.cn::H5 WEB前端设计开发!" />
		<meta name="author" content="DeathGhost" />
		<link href="style/style.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="js/public.js"></script>
		<script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" src="js/jqpublic.js"></script>
		<script type="text/javascript" src="js/cart.js"></script>
		<script type="text/javascript" src="/webjars/jquery/3.4.1/jquery.min.js"></script>
		<script type="text/javascript">
			$(function() {
				//声明一个在结算时被选中的食品的map 食品id 食品数量
				var foodId = new Array();
				//刷新购物车列表
				function getCar() {
					$.ajax({
						url: "/car/lookCar",
						type: "GET",
						dataType: "JSON",
						success: function(data) {
							//刷新前清空
							foodId = new Array();
							$("#shuliang").html("0");
							$("#zong1").html("0.00")
							$("#foodCar").html("");
							getZong()
							var tab;
							$.each(data, function(index, v) {
								tab = $("<table cellpadding='0' cellspacing='0' class='gwc_tb2' ></table>")
								tab.append($("<tr></tr>").append($("<td colspan='7' class='shopname Font14 FontW'></td>").html("店铺：" + v.shopname)))
								$.each(v.foodList, function(index, f) {
									tab.append($("<tr></tr>")
										.append($("<td class='tb2_td1'></td>").append($("<input type='checkbox' class='checkboxFood' value='" + f.id + "' name='newlist' />").click(function jstotal() {
											if($(this).prop("checked")) {
												$("#shuliang").html(Number($("#shuliang").html()) + 1)
												$("#zong1").html(Number($("#zong1").html()) + (f.sellPrice * f.foodNum) + ".00")
												getZong()
											} else {
												$("#shuliang").html(Number($("#shuliang").html()) - 1)
												$("#zong1").html(Number($("#zong1").html()) - (f.sellPrice * f.foodNum) + ".00")
												getZong()
											}
										})))
										.append($("<td class='tb2_td2'></td>").append($("<a href='detailsp.html' target='_blank'></a>").append($("<img src='upload/01.jpg' />"))))
										.append($("<td class='tb2_td3'></td>").append($("<a href='detailsp.html' target='_blank'></a>").html(f.title)))
										.append($("<td class='tb1_td4'></td>").append($("<s></s>").html("￥" + f.sellPrice + ".00")))
										.append($("<td class='tb1_td5'></td>")
											.append($('<input type="hidden" />').val(f.id))
											.append($('<input class="min1" name=""  style="width:30px; height:30px;border:1px solid #ccc;" type="button" value="-" />').click(function() {
												$.ajax({
													url: "/car/loseFoodNum?id=" + f.id,
													type: "GET",
													dataType: "json",
													success: function(data) {
														if(data == 1) {
															getCar()
														}
													}
												})
											}))
											.append($('<input class="text_box1" name="" type="text" style=" width:40px;height:28px; text-align:center; border:1px solid #ccc;" />').val(f.foodNum))
											.append($('<input class="add1" name="" style="width:30px; height:30px;border:1px solid #ccc;" type="button" value="+" />').click(function() {

												$.ajax({
													url: "/car/plusFoodNum?id=" + f.id,
													type: "GET",
													dataType: "json",
													success: function(data) {
														if(data == 1) {
															getCar()
														}
													}
												})
											}))
										)
										.append($("<td class='tb1_td6'></td>").append($('<label id="total1" class="tot" style="color:#ff5500;font-size:14px; font-weight:bold;"></label>').html(f.sellPrice + ".00")))
										.append($("<td class='tb1_td7'></td>").append($('<a href="#" id="delcart1"></a>').html("删除").click(function() {
											$.ajax({
												url: "/car/delCarFood?id=" + f.id,
												type: "GET",
												dataType: "json",
												success: function(data) {
													if(data == 1) {
														getCar()
													}
												}
											})
										})))
									)
								});
							})
							//将商品加入页面
							$("#foodCar").append(tab);
						}
					})
				}
				//刷新结算按钮显示与隐藏
				function getZong() {
					if(Number($("#zong1").html()) != 0) {
						$("#jz1").css("display", "none");
						$("#jz2").css("display", "block")
					} else {
						$("#jz1").css("display", "block");
						$("#jz2").css("display", "none")
					}
				}

				//加载页面时刷新购物车
				getCar();
				//结算选中的食品
				$("#jz2").click(function() {
					//将食品id数组传入后台
					$(".checkboxFood").each(function() {
						if($(this).prop("checked")) {
							foodId.push($(this).val())
						}
					})
					$.ajax({
						url: "/car/jsTotal",
						type: "get",
						data: {
							"foodId": foodId
						},
						success: function(data) {

						}
					});
				})
			})
		</script>
		<!--
Author: DeathGhost
Author URI: http://www.deathghost.cn
-->
	</head>

	<body>
		<header>
			<section class="Topmenubg">
				<div class="Topnav">
					<div class="LeftNav">
						<a href="register.html">注册</a>/
						<a href="login.html">登录</a>
						<a href="#">QQ客服</a>
						<a href="#">微信客服</a>
						<a href="#">手机客户端</a>
					</div>
					<div class="RightNav">
						<a href="user_center.html">用户中心</a>
						<a href="user_orderlist.html" target="_blank" title="我的订单">我的订单</a>
						<a href="cart.html">购物车（0）</a>
						<a href="user_favorites.html" target="_blank" title="我的收藏">我的收藏</a>
						<a href="#">商家入驻</a>
					</div>
				</div>
			</section>
			<div class="Logo_search">
				<div class="Logo">
					<img src="images/logo.jpg" title="DeathGhost" alt="模板">
					<i></i>
					<span>西安市 [ <a href="#">莲湖区</a> ]</span>
				</div>
				<div class="Search">
					<form method="get" id="main_a_serach" onsubmit="return check_search(this)">
						<div class="Search_nav" id="selectsearch">
							<a href="javascript:;" onClick="selectsearch(this,'restaurant_name')" class="choose">餐厅</a>
							<a href="javascript:;" onClick="selectsearch(this,'food_name')">食物名</a>
						</div>
						<div class="Search_area">
							<input type="search" id="fkeyword" name="keyword" placeholder="请输入您所需查找的餐厅名称或食物名称..." class="searchbox" />
							<input type="submit" class="searchbutton" value="搜 索" />
						</div>
					</form>
					<p class="hotkeywords">
						<a href="#" title="酸辣土豆丝">酸辣土豆丝</a>
						<a href="#" title="这里是产品名称">螃蟹炒年糕</a>
						<a href="#" title="这里是产品名称">牛奶炖蛋</a>
						<a href="#" title="这里是产品名称">芝麻酱凉面</a>
						<a href="#" title="这里是产品名称">滑蛋虾仁</a>
						<a href="#" title="这里是产品名称">蒜汁茄子</a>
					</p>
				</div>
			</div>
			<nav class="menu_bg">
				<ul class="menu">
					<li>
						<a href="index.html">首页</a>
					</li>
					<li>
						<a href="list.html">订餐</a>
					</li>
					<li>
						<a href="category.html">积分商城</a>
					</li>
					<li>
						<a href="article_read.html">关于我们</a>
					</li>
				</ul>
			</nav>
		</header>
		<!--Start content-->
		<form action="#">
			<div class="gwc" style=" margin:auto;">
				<table cellpadding="0" cellspacing="0" class="gwc_tb1">
					<tr>
						<td class="tb1_td1">选择</td>
						<td class="tb1_td1"></td>
						<td class="tb1_td3">商品</td>
						<td class="tb1_td4">原价</td>
						<td class="tb1_td5">数量</td>
						<td class="tb1_td6">单价</td>
						<td class="tb1_td7">操作</td>
					</tr>
				</table>
				<div id="foodCar"></div>
				<!--<table cellpadding="0" cellspacing="0" class="gwc_tb2" id="table1">
    <tr>
     <td colspan="7" class="shopname Font14 FontW">店铺：好味来快餐店</td>
    </tr>
    <tr>
      <td class="tb2_td1"><input type="checkbox" value="1" name="newslist" id="newslist-1" /></td>
      <td class="tb2_td2"><a href="detailsp.html" target="_blank"><img src="upload/01.jpg"/></a></td>
      <td class="tb2_td3"><a href="detailsp.html" target="_blank">酸辣土豆丝</a></td>
      <td class="tb1_td4"><s>￥59.00</s></td>
      <td class="tb1_td5"><input id="min1" name=""  style="width:30px; height:30px;border:1px solid #ccc;" type="button" value="-" />
        <input id="text_box1" name="" type="text" value="1" style=" width:40px;height:28px; text-align:center; border:1px solid #ccc;" />
        <input id="add1" name="" style="width:30px; height:30px;border:1px solid #ccc;" type="button" value="+" />
      </td>
      <td class="tb1_td6"><label id="total1" class="tot" style="color:#ff5500;font-size:14px; font-weight:bold;"></label></td>
      <td class="tb1_td7"><a href="#" id="delcart1">删除</a></td>
    </tr>
  </table>
  <table cellpadding="0" cellspacing="0" class="gwc_tb2" id="table2">
    <tr>
     <td colspan="7" class="shopname Font14 FontW">店铺：肯德基</td>
    </tr>
    <tr>
      <td class="tb2_td1"><input type="checkbox" value="1" name="newslist" id="newslist-2" /></td>
      <td class="tb2_td2"><a href="detailsp.html" target="_blank"><img src="upload/02.jpg"/></a></td>
      <td class="tb2_td3"><a href="detailsp.html" target="_blank">酸辣土豆丝</a></td>
      <td class="tb1_td4"><s>￥59.00</s></td>
      <td class="tb1_td5"><input id="min2" name=""  style=" width:30px; height:30px;border:1px solid #ccc;" type="button" value="-" />
        <input id="text_box2" name="" type="text" value="1" style=" width:40px;height:28px; text-align:center; border:1px solid #ccc;" />
        <input id="add2" name="" style=" width:30px; height:30px;border:1px solid #ccc;" type="button" value="+" />
      </td>
      <td class="tb1_td6"><label id="total2" class="tot" style="color:#ff5500;font-size:14px; font-weight:bold;"></label></td>
      <td class="tb1_td7"><a href="#" id="delcart2">删除</a></td>
    </tr>
  </table>-->
				<table cellpadding="0" cellspacing="0" class="gwc_tb3">
					<tr>
						<td class="tb1_td1"></td>
						<td class="tb1_td1"></td>
						<td class="tb3_td1"></td>
						<td class="tb3_td2 GoBack_Buy Font14">
							<a href="index.html" target="_blank">继续购物</a>
						</td>
						<td class="tb3_td2">已选商品
							<label id="shuliang" style="color:#ff5500;font-size:14px; font-weight:bold;">0</label> 件
						</td>
						<td class="tb3_td3">合计(不含运费):<span>￥</span><span style=" color:#ff5500;">
        <label id="zong1" style="color:#ff5500;font-size:14px; font-weight:bold;">0.00</label>
        </span></td>
						<td class="tb3_td4"><span id="jz1">结算</span>
							<a href="confirm_order.html" style=" display:none;" class="jz2" id="jz2">结算</a>
						</td>
					</tr>
				</table>
			</div>
		</form>
		<!--End content-->
		<div class="F-link">
			<span>友情链接：</span>
			<a href="http://www.htmlsucai.com" target="_blank" title="DeathGhost">DeathGhost</a>
			<a href="http://www.htmlsucai.com" target="_blank" title="免费后台管理模板">绿色清爽版通用型后台管理模板免费下载</a>
			<a href="http://www.htmlsucai.com" target="_blank" title="果蔬菜类模板源码">HTML5果蔬菜类模板源码</a>
			<a href="http://www.htmlsucai.com" target="_blank" title="黑色的cms商城网站后台管理模板">黑色的cms商城网站后台管理模板</a>
		</div>
		<footer>
			<section class="Otherlink">
				<aside>
					<div class="ewm-left">
						<p>手机扫描二维码：</p>
						<img src="images/Android_ico_d.gif">
						<img src="images/iphone_ico_d.gif">
					</div>
					<div class="tips">
						<p>客服热线</p>
						<p><i>1830927**73</i></p>
						<p>配送时间</p>
						<p><time>09：00</time>~<time>22:00</time></p>
						<p>网站公告</p>
					</div>
				</aside>
				<section>
					<div>
						<span><i class="i1"></i>配送支付</span>
						<ul>
							<li>
								<a href="article_read.html" target="_blank" title="标题">支付方式</a>
							</li>
							<li>
								<a href="article_read.html" target="_blank" title="标题">配送方式</a>
							</li>
							<li>
								<a href="article_read.html" target="_blank" title="标题">配送效率</a>
							</li>
							<li>
								<a href="article_read.html" target="_blank" title="标题">服务费用</a>
							</li>
						</ul>
					</div>
					<div>
						<span><i class="i2"></i>关于我们</span>
						<ul>
							<li>
								<a href="article_read.html" target="_blank" title="标题">招贤纳士</a>
							</li>
							<li>
								<a href="article_read.html" target="_blank" title="标题">网站介绍</a>
							</li>
							<li>
								<a href="article_read.html" target="_blank" title="标题">配送效率</a>
							</li>
							<li>
								<a href="article_read.html" target="_blank" title="标题">商家加盟</a>
							</li>
						</ul>
					</div>
					<div>
						<span><i class="i3"></i>帮助中心</span>
						<ul>
							<li>
								<a href="article_read.html" target="_blank" title="标题">服务内容</a>
							</li>
							<li>
								<a href="article_read.html" target="_blank" title="标题">服务介绍</a>
							</li>
							<li>
								<a href="article_read.html" target="_blank" title="标题">常见问题</a>
							</li>
							<li>
								<a href="article_read.html" target="_blank" title="标题">网站地图</a>
							</li>
						</ul>
					</div>
				</section>
			</section>
			<div class="copyright">(c) 版权所有 2016 DeathGhost 技术支持：
				<a href="http://www.htmlsucai.com" title="DeathGhost">DeathGhost</a>
			</div>
		</footer>
	</body>

</html>